module while_loop;

    byte a;

    initial begin
        begin: do_while_loop
            $display("do-while loop example:");
            // do while 循环至少执行一次
            a = 0;
            do begin
                $display ("Current value of a = %g", a);
                a += 1;
            end while (a < 1);
        end

        begin: while_loop
            $display("while loop example:");
            // while 循环在条件为真时执行
            a = 0;
            while (a < 15) begin
                if (a == 8) begin
                    $display("Calling break statement at a = %0d", a);
                    break;
                end
                $display ("Current value of a = %g", a);
                a += 1;
            end
        end
        #1 $finish;
    end

endmodule
